package cn.xfdzx.android.apps.shop.activity;


import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.OnClick;
import cn.xfdzx.android.apps.shop.R;
import cn.xfdzx.android.apps.shop.adapter.HomeClassGVAdapter;
import cn.xfdzx.android.apps.shop.adapter.TypeRetailGVAdapter;
import cn.xfdzx.android.apps.shop.base.BaseMvpActivity;
import cn.xfdzx.android.apps.shop.bean.HomeClassBeen;
import cn.xfdzx.android.apps.shop.bean.OneBeen;
import cn.xfdzx.android.apps.shop.util.StatusBarUtil;

public class TypeActivity extends BaseMvpActivity {

    @BindView(R.id.gv_type)
    GridView gvType;
    @BindView(R.id.tv_type_title)
    TextView tvTypeTitle;
    @BindView(R.id.ll_state)
    LinearLayout llState;
    private TypeRetailGVAdapter typeRetailGVAdapter;
    private OneBeen bean;
    private RelativeLayout.LayoutParams item_bar;
    @Override
    public int getLayoutId() {
        return R.layout.activity_type;
    }

    @Override
    public void initView() {
        initHigh();
        tvTypeTitle.setText(getIntent().getStringExtra("title_name"));
        bean= (OneBeen) getIntent().getSerializableExtra("data");

        typeRetailGVAdapter = new TypeRetailGVAdapter(this);
        gvType.setAdapter(typeRetailGVAdapter);
        gvType.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Intent intent=new Intent();
                intent.putExtra("index",i);
                setResult(RESULT_OK,intent);
                finish();
            }
        });
        typeRetailGVAdapter.setData(bean.getData());
    }
    private void initHigh() {
        item_bar = (RelativeLayout.LayoutParams) llState.getLayoutParams();
        item_bar.height = StatusBarUtil.getStatusBarHeight(this);
        llState.setLayoutParams(item_bar);
    }
    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void onError(Throwable throwable) {

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @OnClick(R.id.iv_back)
    public void OnClick(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                finish();
                break;
        }

    }

    @Override
    protected boolean isUseFullScreenMode() {
        return true;
    }
}
